<template>
  <div>
    <div class="bg_grey_all"></div>
    <van-row>
      <van-col span="24" class="title">
        <span style="color: white">浩物安全管理系统</span>
      </van-col>
    </van-row>
    <van-row class="topMargin">
      <van-col span="24">
        <van-card class="bg_blue" :thumb="head_image">
          <template #title>
            <div style="font-size: 18px">{{ currentUser.name }}</div>
            <!-- <div style="font-size:14px;color:#cccccc">销售部-销售经理</div> -->
            <div style="font-size: 14px; margin-top: 20px">
              {{ currentUser.companyName }}
            </div>
          </template>
        </van-card>
      </van-col>
    </van-row>

    <van-row>
      <van-col span="24" class="bg_grey_height"></van-col>
    </van-row>
    <van-row>
      <van-col span="24">
        <van-cell-group>
          <van-cell
            title="账号与安全"
            icon="setting-o"
            is-link
            @click="redirectSubPage('account')"
          />
        </van-cell-group>
      </van-col>
    </van-row>
    <van-row>
      <van-col span="24" class="bg_grey_height"></van-col>
    </van-row>
    <van-row>
      <van-col span="24">
        <van-cell-group>
          <van-cell
            title="实名信息"
            icon="idcard"
            :value="idCardName"
            is-link
            @click="redirectSubPage('idcard')"
          />
          <van-cell
            title="驾驶资质"
            icon="manager-o"
            :value="drivingName"
            is-link
            @click="redirectSubPage('drivingLicense')"
          />
        </van-cell-group>
      </van-col>
    </van-row>
  </div>
</template>

<script>
import { Api, base_uri } from "../../api/api_config";

export default {
  data() {
    return {
      currentUser: {},
      head_image: "",
      base_uri: "",
      idCardName: '未提交',
      drivingName: '未提交'
    };
  },
  created() {
    this.initData();
  },
  methods: {
    initData() {
      this.base_uri = base_uri;
      this.$store.state.tab_show = true;
      this.currentUser = this.$store.state.configuration.currentUser;
      this.getUserAvatar();
      this.getCertificationData();
    },
    redirectSubPage(e) {
      this.$store.state.tab_show = false;
      this.$router.push("/personalInfo/" + e);
    },
    getUserAvatar() {
      let that = this;
      this.$axios({
        method: Api.file.file.method,
        url:
          Api.file.file.url + "?linkid=" + this.currentUser.id + "&filetype=8",
      })
        .then(function (res) {
          that.head_image = that.base_uri + res.data[0].file_path;
        })
        .catch(function (e) {
          console.log(e);
        });
    },
    getCertificationData() {
      // let that = this;
      this.$axios({
        method: Api.certification.certification.method,
        url:
          Api.certification.certification.url + "?UserId=" + this.currentUser.id,
      })
        .then(function (res) {
          console.log(res)
        })
        .catch(function (e) {
          console.log(e);
        });
    }
  },
};
</script>

<style scoped>
</style>